package com.example.lvsuo.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.lvsuo.entity.SystemUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.lvsuo.entity.vo.SystemUserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 系统用户表，登录用的 Mapper 接口
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@Mapper
public interface SystemUserMapper extends BaseMapper<SystemUser> {

    @Select("select * from system_user where user_name=#{value} and user_status='Y'")
    SystemUser queryUserByUsername(String username);

    @Update("update system_user set user_login_num=user_login_num+1 where user_name=#{userName}")
    void upLoginNum(SystemUser userName);


    List<SystemUser> getSystemUser( SystemUserVo systemUserVo);

    @Select(" SELECT LAST_INSERT_ID() ")
    Long getNewId();

    List<SystemUserVo> getxiangqing(String id);

//    void updateSystemUser(SystemUserVo systemUservo);

    void updateSystemUserRole(SystemUserVo systemUservo);

    @Select(" select * from system_user where id = #{id} ")
    SystemUser KSlogin(String id);

    @Select(" select id from  system_user where user_name=${userName} ")
    String getUserByName(String userName);

    void addSysRole(SystemUserVo systemUserVo);

    void addSysUser(SystemUserVo systemUserVo);

    List<SystemUserVo> getSystemUserRoleId(String id);
}
